import allure
from selenium.webdriver.common.by import By

from base.base import Base

class pageRegister(Base):

    # 输入手机号码
    @allure.step("1、输入手机号码")
    def __input_phone(self,phone):
        self.element_send_keys((By.CSS_SELECTOR,'#username'),phone)
    # 输入验证码
    @allure.step("2、输入验证码")
    def __input_verify_code(self,code):
        self.element_send_keys((By.CSS_SELECTOR,"input[placeholder='图像验证码']"),code)
    # 输入密码
    @allure.step("3、输入密码")
    def __input_password(self,password):
        self.element_send_keys((By.CSS_SELECTOR,'#password'),password)
    # 输入确认密码
    @allure.step("4、输入确认密码")
    def __input_confirm_password2(self,password2):
        self.element_send_keys((By.CSS_SELECTOR,'#password2'),password2)
    # 输入推荐人手机号
    @allure.step("5、输入推荐人手机号")
    def __input_invite(self,invite):
        self.element_send_keys((By.CSS_SELECTOR,"input[placeholder='请输入手机号码'][name='invite']"),invite)
    # 点击注册按钮
    @allure.step("6、点击注册按钮")
    def __click_register_button(self):
        self.element_click((By.CSS_SELECTOR,'.regbtn.J_btn_agree'))

    # 获取错误的信息
    def get_error_message(self):
        return self.get_text((By.CSS_SELECTOR,'.layui-layer-content.layui-layer-padding'))
    def  register(self,phone,code,password,password2,invite):
        self.__input_phone(phone)
        self.__input_verify_code(code)
        self.__input_password(password)
        self.__input_confirm_password2(password2)
        self.__input_invite(invite)
        self.__click_register_button()